#include <iostream>
#include <memory>

struct C : std::enable_shared_from_this<C>
{
    int v;

    void act() {
        std::shared_ptr<C> ins(shared_from_this());
        ins->v += 1;
        std::cout << "v: " << ins->v << " refs: " << ins.use_count() << std::endl;
    }
};

int main() {
    std::shared_ptr<C> c(std::make_shared<C>());

    c->act();

    std::shared_ptr<C> d(std::move(c));
    d->act();

    return 0;
}
